home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Freeware / Adobe AIR 1.5.1 / AdobeAIRInstaller.exe / setup.swf / scripts / mx / utils / XMLNotifier.as < prev   
Encoding:
Text File  |  2009-02-12  |  2.6 KB  |  95 lines

  1. package mx.utils
  2. {
  3.    import flash.utils.Dictionary;
  4.    import mx.core.mx_internal;
  5.    
  6.    use namespace mx_internal;
  7.    
  8.    public class XMLNotifier
  9.    {
  10.       private static var instance:XMLNotifier;
  11.       
  12.       mx_internal static const VERSION:String = "3.0.0.0";
  13.       
  14.       public function XMLNotifier(param1:XMLNotifierSingleton)
  15.       {
  16.          super();
  17.       }
  18.       
  19.       public static function getInstance() : XMLNotifier
  20.       {
  21.          if(!instance)
  22.          {
  23.             instance = new XMLNotifier(new XMLNotifierSingleton());
  24.          }
  25.          return instance;
  26.       }
  27.       
  28.       mx_internal static function initializeXMLForNotification() : Function
  29.       {
  30.          var notificationFunction:Function = function(param1:Object, param2:String, param3:Object, param4:Object, param5:Object):void
  31.          {
  32.             var _loc8_:Object = null;
  33.             var _loc7_:Dictionary = arguments.callee.watched;
  34.             if(_loc7_ != null)
  35.             {
  36.                for(_loc8_ in _loc7_)
  37.                {
  38.                   IXMLNotifiable(_loc8_).xmlNotification(param1,param2,param3,param4,param5);
  39.                }
  40.             }
  41.          };
  42.          return notificationFunction;
  43.       }
  44.       
  45.       public function watchXML(param1:Object, param2:IXMLNotifiable, param3:String = null) : void
  46.       {
  47.          var _loc6_:Dictionary = null;
  48.          var _loc4_:XML = XML(param1);
  49.          var _loc5_:Object = _loc4_.notification();
  50.          if(!(_loc5_ is Function))
  51.          {
  52.             _loc5_ = mx_internal::initializeXMLForNotification();
  53.             _loc4_.setNotification(_loc5_ as Function);
  54.             if(Boolean(param3) && _loc5_["uid"] == null)
  55.             {
  56.                _loc5_["uid"] = param3;
  57.             }
  58.          }
  59.          if(_loc5_["watched"] == undefined)
  60.          {
  61.             _loc5_["watched"] = _loc6_ = new Dictionary(true);
  62.          }
  63.          else
  64.          {
  65.             _loc6_ = _loc5_["watched"];
  66.          }
  67.          _loc6_[param2] = true;
  68.       }
  69.       
  70.       public function unwatchXML(param1:Object, param2:IXMLNotifiable) : void
  71.       {
  72.          var _loc5_:Dictionary = null;
  73.          var _loc3_:XML = XML(param1);
  74.          var _loc4_:Object = _loc3_.notification();
  75.          if(!(_loc4_ is Function))
  76.          {
  77.             return;
  78.          }
  79.          if(_loc4_["watched"] != undefined)
  80.          {
  81.             _loc5_ = _loc4_["watched"];
  82.             delete _loc5_[param2];
  83.          }
  84.       }
  85.    }
  86. }
  87.  
  88. class XMLNotifierSingleton
  89. {
  90.    public function XMLNotifierSingleton()
  91.    {
  92.       super();
  93.    }
  94. }
  95.